package com.easyadmin.pro.common.exception;

import com.easyadmin.pro.common.enums.HttpCodeEnum;
import lombok.Data;

/**
 * packageName com.easyadmin.pro.common.exception
 *
 * @author 骑着蚂蚁去上天
 * @version JDK 17
 * @className EasyAdminProBaseException
 * @date 2024/4/1
 * @description 基础异常
 */
@Data
public class EasyAdminProBaseException extends RuntimeException {

    private int code;

    /**
     * 使用枚举构造
     * @param httpCodeEnum
     */
    public EasyAdminProBaseException(HttpCodeEnum httpCodeEnum){
        super(httpCodeEnum.getMsg());
        this.code=httpCodeEnum.getCode();
    }

    /**
     * 使用自定义消息体
     * @param httpCodeEnum
     * @param msg
     */
    public EasyAdminProBaseException(HttpCodeEnum httpCodeEnum, String msg){
        super(msg);
        this.code=httpCodeEnum.getCode();
    }

    /**
     * 根据异常构造
     * @param httpCodeEnum
     * @param msg
     */
    public EasyAdminProBaseException(HttpCodeEnum httpCodeEnum, Throwable msg){
        super(msg);
        this.code=httpCodeEnum.getCode();
    }
}